home *** CD-ROM | disk | FTP | other *** search
/ Zoom 2 / Zoom - Release 2 (1996)(Active Software)[!].iso / utilities / comms / irc / grapevine / rexx / faq.gvrexx < prev    next >
Encoding:
Text File  |  1995-07-13  |  4.7 KB  |  178 lines

  1. /* Grapevine FAQ script v1.0
  2.     Only works on Grapevine 2 ßeta versions (ie v1.365)
  3.     Needs standard AmigaDOS list, sort, and delete commands to work 100%
  4.    Assign a directory FAQ: containing your faq files
  5.     /Alias faq faq.gv to use the /faq command in gv (add to startup.gv)
  6. @
  7.     Grapevine FAQ command help:
  8.    Usage: /faq file [nick] - Leave off [nick] to send to channel
  9.     or     /faq command arg - See below for details on each command
  10. 
  11.     ADD   <faqname> <faqtext> - Adds a faq to your list
  12.     DEL   <faqname>           - Deletes a faq named <faqname>
  13.     UNDEL <faqname>           - Restores deleted faq to <faqname>
  14.     REN   <faqname> <newname> - Renames <faqname> to <newname>
  15.     LIST                      - Lists all of your faqs in order
  16.     LIST  #                   - Lists faqs to the current channel    
  17.     LIST  [nick]              - Lists faq to [nick]
  18.     VIEW  <faqname>           - Views a faq locally (not to channel)
  19.     EDIT  <faqname> [editor]  - Uses <editor> to edit <faqname>
  20.                              - set to your default editor in source
  21. @
  22.     Maximum length is 512 characters.. change it if you think its safe :)
  23.     Written by Josef Faulkner (panther@gate.net) IRC: Josef on June 14 1995
  24. */
  25. /** Change this if you dont want to type in the editor every time **/
  26. /** ------------------------------------------------------------- **/
  27. /**/                    EditorDefault = 'Ed'                     /**/
  28. /** ------------------------------------------------------------- **/
  29. options results
  30. parse arg faq name faqtext
  31. bb=''
  32. uu=''
  33. ii=''
  34. faq=strip(faq)
  35. name=strip(name)
  36. faqtext=strip(faqtext)
  37. if upper(faq)='ADD' then do
  38.     if exists('FAQ:'name) then do
  39.         'echo 'bb||name||bb' FAQ already exists.'
  40.         'echo Use 'bb'/FAQ DEL <faqname>'bb' to remove it.'
  41.     end
  42.     else do
  43.         call open(1,'FAQ:'name,w)
  44.         call writeln(1,faqtext)
  45.         call close(1)
  46.         'echo 'bb||name||bb' added.  Use 'bb'/FAQ view 'name||bb' to see it without sending.'
  47.     end
  48. end
  49. else if upper(faq)='DEL' then do
  50.     if exists('FAQ:'name) then do
  51.         address command 'copy faq:'name' faq:BAK'
  52.         address command 'delete faq:'name
  53.         'echo 'bb||name||bb' deleted.  It has been backed up to 'uu'FAQ:BAK'uu
  54.     end
  55.     else do
  56.         'echo 'bb||name||bb' not found.'
  57.     end
  58. end
  59. else if upper(faq)='UNDEL' then do
  60.     faqtext=word(faqtext,1)
  61.     if exists('FAQ:BAK') then do
  62.         address command 'copy faq:bak faq:'faqtext
  63.         'echo Backup faq restored to 'bb||faqtext||bb'.'
  64.     end
  65.     else do
  66.         'echo No backup exists.'
  67.     end
  68. end
  69. else if upper(faq)='LIST' then do
  70.     address command 'list FAQ:~(BAK) lformat %n >T:faq.list'
  71.     address command 'sort T:faq.list T:faq.list.sorted'
  72.     address command 'delete T:faq.list'
  73.     if exists('T:faq.list.sorted') then do
  74.         call open(1,'T:faq.list.sorted',r)
  75.         outtext=uu'FAQ List:'uu' '
  76.         do until eof(1)
  77.             text=strip(readln(1))
  78.             outtext=outtext' 'text
  79.         end
  80.         outtext=left(outtext,512)
  81.         if upper(name)='#' then do
  82.             'say 'outtext
  83.         end
  84.         else if upper(name)='' then do
  85.             'echo 'outtext
  86.         end
  87.         else do
  88.             'msg 'name' 'outtext
  89.         end
  90.         call close(1)
  91.         address command 'delete t:faq.list.sorted'
  92.     end
  93.     else 'echo No FAQ''s exist.'
  94. end    
  95. else if upper(faq)='EDIT' then do
  96.     if exists('faq:'name) then do
  97.         if faqtext='' then faqtext=editordefault
  98.         address command 'run 'faqtext' faq:'name
  99.     end
  100.     else do
  101.         'echo 'bb||name||bb' doesnt exist.'
  102.     end
  103. end
  104. else if upper(faq)='VIEW' then do
  105.     if exists('faq:'name) then do
  106.         call open(1,'FAQ:'name,r)
  107.         outtext='FAQ ('name'): '
  108.         do until eof(1)
  109.             text=strip(readln(1))
  110.             outtext=outtext' 'text
  111.         end
  112.         outtext=left(outtext,512)
  113.         'echo 'outtext
  114.         call close(1)
  115.     end
  116.     else do
  117.         'echo 'bb||faq||bb' not found.'
  118.     end
  119. end
  120. else if upper(faq)='REN' then do
  121.     if exists('faq:'name) then do
  122.         if exists('faq:'faqtext)=0 then do
  123.             address command 'rename faq:'name' faq:'faqtext
  124.             'echo 'bb||name||bb' renamed to 'bb||faqtext||bb'.'
  125.         end
  126.         else do
  127.             'echo Attempt to rename to existing file: 'bb||faqtext||bb' already exists.'
  128.         end
  129.     end
  130.     else do
  131.         'echo 'bb||name||bb' does not exist.'
  132.     end
  133. end    
  134. else if upper(faq)='HELP' then do
  135.     send=0
  136.     if exists('faq.gv') then do
  137.         call open(1,'faq.gv')
  138.         do until eof(1)
  139.             text=readln(1)
  140.             if text='@' then send=1-send
  141.             else if send then 'echo 'strip(text,b,'    ')
  142.         end
  143.     end
  144.     else if exists('SYS:rexx/faq.gv') then do
  145.         call open(1,'SYS:rexx/faq.gv')
  146.         do until eof(1)
  147.             text=readln(1)
  148.             if text='@' then send=1-send
  149.             else if send then 'echo 'strip(text,b,'    ')
  150.         end
  151.     end
  152.     else do
  153.         'echo Could not find arexx program in current directory.'
  154.     end
  155. end
  156. else do
  157.     if exists('faq:'faq) then do
  158.         call open(1,'FAQ:'faq,r)
  159.         outtext='FAQ ('faq'): '
  160.         do until eof(1)
  161.             text=strip(readln(1))
  162.             outtext=outtext' 'text
  163.         end
  164.         outtext=left(outtext,512)
  165.         if name~='' then do
  166.             msg name outtext
  167.         end
  168.         else do
  169.              'say 'outtext
  170.         end
  171.         call close(1)
  172.     end
  173.     else do
  174.         'echo 'bb||faq||bb' not found.'
  175.     end
  176. end
  177. exit
  178.